﻿namespace StudyCompanion.Commons.Page;

/// <summary>
///     分页查询对象
/// </summary>
public class PageSearch : IPageSearch
{
    private int _pageIndex;
    private int _pageSize;

    /// <summary>
    ///     页码
    /// </summary>
    public int PageIndex
    {
        get => _pageIndex < 1 ? 1 : _pageIndex;
        set => _pageIndex = value;
    }

    /// <summary>
    ///     每页显示条数
    /// </summary>
    public int PageSize
    {
        get
        {
            if (_pageSize < 5) _pageSize = 5;
            if (_pageSize > 100) _pageSize = 100;
            return _pageSize;
        }
        set => _pageSize = value;
    }
}

/// <summary>
///     分页查询对象
/// </summary>
/// <typeparam name="T"></typeparam>
public class PageSearchModel<T> : PageSearch
{
    /// <summary>
    ///     分页查询值
    /// </summary>
    public T Value { get; set; }
}